package com.xiaohui.sku.controller;


import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @RequestMapping("/test")
    public String test() {
        return "sku";
    }


    @GetMapping("/testHystrix")
    public String testHystrix() {
        return "testHystrix";
    }

    @GetMapping("/testHystrixTimeout")
    @HystrixCommand(fallbackMethod = "testHystrixTimeoutHandler",commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "3000")
    })
    public String testHystrixTimeout() throws InterruptedException {
        Thread.sleep(5000);
        return "testHystrixTimeout";
    }

    public String testHystrixTimeoutHandler() {
        return "降级啦！！！";
    }

}
